<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('学生详情')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form class="form-horizontal m" id="form-student-edit" >
                <input name="studentId" th:field="*{teachingStudent.studentId}" type="hidden">
                <div class="form-group">
                    <div class="col-sm-6">
                        <label class="col-sm-3 control-label">学生姓名：</label>
                        <div class="col-sm-8">
                            <div class="form-control">[[*{teachingStudent.studentName}]]</div>
                        </div>
                    </div>
                    <div class="col-sm-6">
                        <label class="col-sm-3 control-label">出生日期：</label>
                        <div class="col-sm-8">
                            <div class="form-control">[[${#dates.format(teachingStudent.birthday,
                                'yyyy-MM-dd')}]]
                            </div>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-6">
                        <label class="col-sm-3 control-label">主要号码：</label>
                        <div class="col-sm-8">
                            <div class="form-control"
                                 th:text="|${@dict.getLabel('sys_family_ref', teachingStudent.familyRefMain)} ${teachingStudent.phonenumber}|"></div>
                        </div>
                    </div>
                    <div class="col-sm-6">
                        <label class="col-sm-3 control-label">次要号码：</label>
                        <div class="col-sm-8">
                            <div class="form-control"
                                 th:text="|${@dict.getLabel('sys_family_ref', teachingStudent.familyRefMinor)} ${teachingStudent.phonenumberMinor}|"></div>
                        </div>
                    </div>
                </div>

                <div class="form-group">
                    <div class="col-sm-6">
                        <label class="col-sm-3 control-label">性别：</label>
                        <div class="col-sm-8">
                            <div class="form-control"
                                 th:text="${@dict.getLabel('sys_user_sex', teachingStudent.sex)}"></div>
                        </div>
                    </div>
                    <div class="col-sm-6">
                        <label class="col-sm-3 control-label">年级：</label>
                        <div class="col-sm-8">
                            <div class="form-control">[[*{teachingStudent.grade}]]</div>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-6">
                        <label class="col-sm-3 control-label">备注：</label>
                        <div class="col-sm-8">
                            <div class="form-control">[[*{teachingStudent.remark}]]</div>
                        </div>
                    </div>
                    <div class="col-sm-6">
                        <label class="col-sm-3 control-label"></label>
                        <div class="col-sm-8">
                            <div class="btn-group-sm" role="group">
                                <a class="btn btn-info" id="btn-apply">报名</a>
                                <a class="btn btn-success" id="btn-edit">编辑</a>
                                <!--                                <a class="btn btn-info" id="btn-renew">续费</a>-->

                            </div>
                        </div>
                    </div>
                </div>
            </form>
            <div class="tabs-container" style="padding-top: 20px;">
                <ul class="nav nav-tabs">
                    <li class="active"><a data-toggle="tab" href="#tab-1" aria-expanded="true">课程</a>
                    </li>
                    <!--                    <li class=""><a data-toggle="tab" href="#tab-2" aria-expanded="false">班级信息</a>-->
                    <!--                    </li>-->
                </ul>
                <div class="row">
                    <div class="col-sm-3">
                        <div class="panel-default " style="margin: 25px"
                             th:each="teachingStudentApply : ${studentApplys}">
                            <input name="applyId1" th:value="*{teachingStudentApply.applyId}" type="hidden">
                            <div class="panel-body">
                                <div class="col-md-12">
                                    <div class="form-group">
                                        <label class="col-sm-4 control-label"
                                               style="margin: 0; padding: 0px">课程名：</label>
                                        <div class="col-sm-8">
                                            <p class="form-control-static" style="padding: 0px">
                                                [[${teachingCourse.name}]]</p>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-4 control-label"
                                               style="margin: 0; padding: 0px">所属校区：</label>
                                        <div class="col-sm-8">
                                            <p class="form-control-static" style="padding: 0px">
                                                [[${teachingSchool.name}]]</p>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-4 control-label"
                                               style="margin: 0; padding: 0px">报名时间：</label>
                                        <div class="col-sm-8">
                                            <p class="form-control-static" style="padding: 0px">
                                                [[${#dates.format(teachingStudentApply.createTime, "yyyy-MM-dd")}]]</p>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-4 control-label"
                                               style="margin: 0; padding: 0px">剩余课时：</label>
                                        <div class="col-sm-8">
                                            <p class="form-control-static" style="padding: 0px">
                                                [[${teachingStudentApply.lessonRemain}]]
                                                (总计:[[${teachingStudentApply.lessonCount}]])</p>
                                        </div>
                                    </div>
<!--                                    <if condition="${teachingStudentApply.status} eq 1">-->
<!--                                        <p class="form-control-static">-->
<!--                                            [[${#dates.format(teachingStudentApply.updateTime, "yyyy-MM-dd")}]]-->
<!--                                            已经结课</p>-->
<!--                                        <else/>-->
                                        <a class="btn btn-danger" id="btn-end">结课</a>
                                        <a class="btn btn-warning" id="btn-divide">分班</a>
<!--                                    </if>-->
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="col-sm-9">
                        <div class="tab-content">
                            <div id="tab-1" class="tab-pane active">
                                <div class="panel-body">
                                    <table id="bootstrap-table"></table>
                                </div>
                            </div>
                            <!--                    <div id="tab-2" class="tab-pane">-->
                            <!--                        <div class="panel-body">-->
                            <!--                            <table id="student_course"></table>-->
                            <!--                        </div>-->
                            <!--                    </div>-->
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var prefix = ctx + "teaching/student";
    var studentId = [[${teachingStudent.studentId}]];
    var applyId = $("input[name = 'applyId1']").val();
    var removeFlag = [[${@permission.hasPermi('teaching:apply:remove')}]];
    $("#btn-apply").click(function () {
        var url = prefix + "/apply/" + studentId;
        $.modal.open("报名课程", url, 400, 300);
    })

    $("#btn-edit").click(function () {
        var url = prefix + "/edit/" + studentId;
        $.modal.open("编辑学员", url, 800, 500);
    })

    $("#btn-end").click(function () {
        $.modal.confirm("课程结课后，系统将课程的剩余学费、已失效课时自动转成学校的非课消收入。确定要结课吗？", function () {
            var url = ctx + "teaching/apply/endCourse";
            var data = {"applyId": applyId};
            $.operate.post(url, data, function (r) {
                if (r.code == 0) {
                    refreshTab();
                    $.modal.alertSuccess("结课成功");
                } else {
                    $.modal.msg(r.msg);
                }
            });
        })
    })

    $("#btn-divide").click(function (){
        var url = ctx + "teaching/student/allotClass/" + applyId;
        $.modal.open("分班选择", url);
    })

    $(function () {
        var options = {
            url: ctx + "teaching/students/list",
            modalName: "班级",
            showSearch: false,
            showRefresh: false,
            showToggle: false,
            showColumns: false,
            pageSize: 3,
            sortName: "status",
            sortOrder: "asc",
            // queryParams: {studentId: studentId},
            columns: [{
                checkbox: false,
                visible: false,
            },
                {
                    field: 'status',
                    title: '状态',
                    formatter: function (value, row, index) {
                        var datas = [[${@dict.getType('sys_students_status')}]];
                        return $.table.selectDictLabel(datas, value);
                    }
                },
                {
                    field: 'teachingClasses.className',
                    title: '班级名称',
                    formatter: function (value, row, index) {
                        return '<a href="javascript:void(0)" onclick="detail(\'' + row.teachingClasses.classId + '\')">' + value + '</a>';
                    }
                },
                {
                    field: 'teachingClasses.teacherName',
                    title: '教室',
                },
                {
                    field: 'teachingClasses.createTime',
                    title: '开班日期',
                    formatter: function (value, row, index) {
                        return $.common.dateFormat(value);
                    }
                },
                {
                    field: 'lessonConsume',
                    title: '已用课时'
                }
                // {
                //     title: '操作',
                //     align: 'center',
                //     formatter: function (value, row, index) {
                //         var actions = [];
                //         actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.studentId + '\')"><i class="fa fa-remove"></i>删除</a> ');
                //         return actions.join('');
                //     }
                // }
            ]
        };
        $.table.init(options);
    });

    /*班级-详细*/
    function detail(classId) {
        var url = ctx + "teaching/classes/info/" + classId;
        $.modal.openTab("班级详情", url);
    }

</script>
</body>
</html>
